from module.static_module.parent.view import AdditionWindowView


from tools.view import *


class DataMergeView(AdditionWindowView):
    def __init__(self, super_model):
        super().__init__(super_model)

    def create_layout_init(self):
        # 绘制标签、内容组件
        # 配置参数
        # 当前模型名
        data_name_ls = self.super_model.data_name_ls
        k_interval_ls = self.super_model.k_interval_ls
        start_time_ls = self.super_model.start_time_ls
        end_time_ls = self.super_model.end_time_ls

        label_config = [
            [LabelMember.DataName, WidgetCategory.Combobox, data_name_ls, []],
            [LabelMember.KInterval, WidgetCategory.Combobox, k_interval_ls, []],
            [LabelMember.StartTime, WidgetCategory.Entry, start_time_ls, []],
            [LabelMember.EndTime, WidgetCategory.Entry, end_time_ls, []]
        ]
        button_config = [
            [ButtonMember.Run, WidgetCategory.Button, None],
        ]
        self.auto_layout = AutoLayout(self.frame, label_config, button_config)
        self.auto_layout.button_command(self)

        bind_change_behavior = [
            [LabelMember.DataName, self.on_data_name_change]
        ]
        self.auto_layout.label_command(bind_change_behavior)

    def on_data_name_change(self):
        # 数量逻辑层的行为
        self.super_model.on_data_name_change()
        # 更新组件数据
        start_time_ls = self.super_model.start_time_ls
        end_time_ls = self.super_model.end_time_ls

        label_config = [
            [LabelMember.StartTime, WidgetCategory.Entry, start_time_ls, [0]],
            [LabelMember.EndTime, WidgetCategory.Entry, end_time_ls, [0]]
        ]
        self.auto_layout.update_label_layout(label_config)




